package StudyCode.summary.regularexpressionsmatch;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UsingTheCapturedTextOfAGroupWithinReplacementPattern {
	public static void main(String[] args) {
		String patternStr = "\\((\\w+)\\)";
		String replaceStr = "<$1>";
		Pattern pattern = Pattern.compile(patternStr);

		CharSequence inputStr = "a (b c) d (ef) g";
		Matcher matcher = pattern.matcher(inputStr);
		String output = matcher.replaceAll(replaceStr);
		System.out.println(output);
	}
}
